# -*- coding: utf-8 -*-
# @Time : 2021/9/17 16:40
# @Author : Mr  jelis
# @Email : 1402615849@qq.com
# @File : today_miaosha_page.py
# @Project : mryx_test
"""今日秒杀页面类"""
from page.base_page import BasePage
from appium.webdriver.common.mobileby import MobileBy as By
class TodayMiaoSha(BasePage):
    """定义定位器"""
    qianggou_locator = (By.XPATH, '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                                  'android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/'
                                  'android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.LinearLayout/'
                                  'android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/'
                                  'android.view.View/android.view.View[1]/android.view.View[3]/android.view.View[6]/android.view.View')
    shopping_locator = (By.XPATH, '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
              'android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/'
              'android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.webkit.WebView/'
              'android.webkit.WebView/android.view.View/android.view.View/android.view.View[2]')
    shangpingname_locator=(By.XPATH,'//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/'
                                    'android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/'
                                    'android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/'
                                    'android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/'
                                    'android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[3]/'
                                    'android.view.View[3]')
    qianggou2_locator = (By.XPATH,'//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[4]/android.view.View[6]/android.view.View[1]')
    def qianggou(self):
        """点击立即抢购"""
        self.driver.find_element(*self.qianggou_locator).click()
    def qianggou2(self):
        """点击立即抢购"""
        self.driver.find_element(*self.qianggou2_locator).click()
    def enter_shopping(self):
        """进入购物车"""
        self.driver.find_element(*self.shopping_locator).click()

    def shangpingname(self):
        text=self.driver.find_element(*self.shangpingname_locator).text
        return text

